<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script>

        function zuigaowei() {

            let a=prompt("请输入一个数");
            while(true){
               g=parseInt(a%10);

                a= parseInt(a/10);
               if(a>=1&&a<=9){
                   return a;
               }


            }


        }
    </script>
</head>
<body>
<input type="button" value="最高位" onclick="alert(zuigaowei())">
</body>
</html>